package com.ss.android.wenda.c;

import android.content.res.Resources;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.detail2.widget.tagview.TagLayout;
import com.ss.android.article.base.ui.EllipsisAppendSuffixTextView;
import com.ss.android.article.browser.R;
import com.ss.android.k.d.c;
import com.ss.android.k.dd;
import com.ss.android.wenda.a.i;
import com.ss.android.wenda.answer.detail2.WDFontUtils;
import com.ss.android.wenda.model.ConcernTag;
import com.ss.android.wenda.model.Question;
import com.ss.android.wenda.ui.MultiStyleTextView;
import im.quar.autolayout.utils.AutoUtils;

import java.util.Collection;
import java.util.Iterator;

public final class l extends dd {
    boolean c;

    public l() {
        this.c = false;
    }

    public final void a(Object arg11) {
        View v0_1;
        int v1 = 3;
        int v0 = 2;
        int v7 = View.GONE;
        if((arg11 instanceof Question)) {
            int v6 = AppData.getInstance().mFontSizePref;
            Resources v5 = this.a().getResources();
            Object v4 = arg11;
            int v2 = this.a().getId();
            if(v2 == R.id.question_title) {
                v0_1 = this.a();
                ((MultiStyleTextView)v0_1).setPadding(((int) UIUtils.dp2px(((MultiStyleTextView)v0_1).getContext(), 40f)));
                ((MultiStyleTextView)v0_1).setAlignRight(true);
                ((MultiStyleTextView)v0_1).setQuestionTextSize(UIUtils.sp2px(((MultiStyleTextView)v0_1).getContext(), ((float)WDFontUtils.a[v6])));
                ((MultiStyleTextView)v0_1).setQuestionTextType(Typeface.DEFAULT_BOLD);
                ((MultiStyleTextView)v0_1).setAnswerCountTextSize(UIUtils.sp2px(((MultiStyleTextView)v0_1).getContext(), ((float)WDFontUtils.b[v6])));
                ((MultiStyleTextView)v0_1).setMultiLineVerticalPadding(((int) UIUtils.dp2px(((MultiStyleTextView)v0_1).getContext(), 16f)));
                ((MultiStyleTextView)v0_1).setLineSpacing(((int) UIUtils.dp2px(((MultiStyleTextView)v0_1).getContext(), 4f)));
                ((MultiStyleTextView)v0_1).setQuestionTextColor(v5.getColor(com.ss.android.article.browser.R.color.ssxinzi1));
                ((MultiStyleTextView)v0_1).b = ((Question)v4).mTitle;
                ((MultiStyleTextView)v0_1).c = "";
                ((MultiStyleTextView)v0_1).d = true;
                if(TextUtils.isEmpty("")) {
                    ((MultiStyleTextView)v0_1).a = 0;
                }

                ((MultiStyleTextView)v0_1).invalidate();
                ((MultiStyleTextView)v0_1).requestLayout();
            }
            else {
                if(v2 == R.id.question_desc) {
                    View v2_1 = this.b().a.findViewById(com.ss.android.article.browser.R.id.divide_line);
                    if(((Question)v4).mQuestionDesc != null && !android.support.design.a.isTextEmpty(((Question)v4).mQuestionDesc.mContent)) {
                        v2_1.setBackgroundColor(v5.getColor(com.ss.android.article.browser.R.color.ssxinxian1));
                        i v2_2 = i.a();
                        if(v2_2.a == null) {
                            v0 = v1;
                        }
                        else {
                            v1 = v2_2.a.optInt("list_question_header_content_fold_max_count", v1);
                            if(v1 > 15) {
                                v0 = 15;
                            }
                            else if(v1 >= v0) {
                                v0 = v1;
                            }
                        }

                        v2_1 = this.c().a;
                        View v3 = this.b().a.findViewById(com.ss.android.article.browser.R.id.question_desc_all);
                        ((EllipsisAppendSuffixTextView)v2_1).setTextSize(((float)WDFontUtils.c[v6]));
                        ((TextView)v3).setTextSize(((float)WDFontUtils.c[v6]));
                        if(this.c) {
                            return;
                        }

                        if(!android.support.design.a.isEmptyCollection((Collection) ((Question)v4).mQuestionDesc.mThumbImages) && !i.a().b().booleanValue()) {
                            ((EllipsisAppendSuffixTextView)v2_1).setForceEllipsis(true);
                        }

                        ((TextView)v3).setVisibility(v7);
                        ((EllipsisAppendSuffixTextView)v2_1).setMaxLines(v0);
                        ((EllipsisAppendSuffixTextView)v2_1).setAppendSuffix("展开");
                        c v0_2 = this.c();
                        v1 = v5.getColor(com.ss.android.article.browser.R.color.ssxinzi2);
                        if((v0_2.a instanceof TextView)) {
                            ((TextView)v0_2.a).setTextColor(v1);
                        }

                        ((EllipsisAppendSuffixTextView)v2_1).setDispatchDrawListener(new m(this, ((EllipsisAppendSuffixTextView)v2_1), ((TextView)v3), ((Question)v4), v5));
                        this.c().d(0).a("描述: " + ((Question)v4).mQuestionDesc.mContent);
                        return;
                    }

                    this.c().d(v7);
                    v2_1.setVisibility(v7);
                    return;
                }

                if(v2 == R.id.tag_layout) {
                    if(android.support.design.a.isEmptyCollection((Collection) ((Question)v4).mConcernTags)) {
                        this.c().d(v7);
                        return;
                    }

                    v0_1 = this.a();
                    if(((TagLayout)v0_1).getChildCount() != 0) {
                        return;
                    }

                    Iterator v2_3 = ((Question)v4).mConcernTags.iterator();
                    while(true) {
                        if(!v2_3.hasNext()) {
                            return;
                        }

                        Object v1_1 = v2_3.next();
                        ((TagLayout)v0_1).setHorizontalSpacing(AutoUtils.scaleValue(12));
                        ((TagLayout)v0_1).setVerticalSpacing(AutoUtils.scaleValue(12));
                        ((TagLayout)v0_1).a(TagLayout.a(((TagLayout)v0_1).getContext(), ((ConcernTag)v1_1).mName), new o(((ConcernTag)v1_1), ((TagLayout)v0_1)));
                    }
                }

                if(v2 != R.id.bottom_view) {
                    return;
                }

                this.a().setBackgroundColor(v5.getColor(com.ss.android.article.browser.R.color.ssxinmian3));
            }
        }
    }
}

